import { ResultInfo } from '..';

export const transform = (data: Record<string, unknown>) => {
  const transformed: Record<string, string> = {};
  for (const [key, value] of Object.entries(data)) {
    if (typeof value === 'object') {
      transformed[key] = JSON.stringify(value);
    } else {
      transformed[key] = String(value);
    }
  }
  return transformed;
};
export const formatReportInfo = (result: ResultInfo): Record<string, string> => {
  const { error_info = {}, ...other_info } = result;
  return {
    ...transform(other_info),
    ...transform(error_info as Record<string, unknown>),
  };
};
